package jianzhiOffer;

import java.util.ArrayList;
import java.util.List;

//剑指 Offer 57 - II. 和为s的连续正数序列
public class Num57_II_findContinuousSequence {
    public int[][] findContinuousSequence(int target) {
        List<int[]>list = new ArrayList<>();
        int i = 1;
        int j = 2;
        int s = 3;
        while (i < j){
            if (s == target){
                int []ans = new int[j - i + 1];
                for (int k = i; k <= j ; k++) {
                    ans[k - i] = k;
                }
                list.add(ans);
            }
            if (s >= target){
                s -= i;
                i++;

            }else {
                j++;
                s += j;
            }

        }
        return list.toArray(new int[0][]);


    }
}
